<?

class dateTimeObject
{
	var $oDate;
	var $oTime;
	function dateTimeObject ( $cValue = '', $cLang = 'es')
		{
			$this->oDate = new DateObject('', $cLang );
			$this->oTime = new TimeObject();
			if ( $cValue ) 	$this->setValue( $cValue );
		}
	function setToday()
	{
		$this->oDate->setToday();
		$this->oTime->setNow();
	}
	function setValue( $cValue )
	{
		list ( $cFecha, $cHora ) = split( " ", $cValue );
		if ( $cFecha )
		{
			$this->oDate->setValue($cFecha) ;
		}
		if ( $cHora  )
		{
			$this->oTime->setValue($cHora) ;
		}
	}
	function getFecha()
	{
		global $MESES2;
		$aFecha = getdate();
		$cFecha = '';
		$cFecha.= $MESES2[$aFecha[mon]];
		$cFecha.= '.';
		$cFecha.= $aFecha[year];
		$cFecha.= ' <b>';
		if ($aFecha[hours]<10) $cFecha.= '0';
		$cFecha.= $aFecha[hours];
		$cFecha.= ':';
		if ($aFecha[minutes]<10) $cFecha.= '0';
		$cFecha.= $aFecha[minutes];
		$cFecha.= ' HS</b>';
		return $cFecha;
	}
	function getValue( $cFormat )
	{
		$cReturn = $cFormat;
		$cReturn = str_replace( "dd", str_pad( $this->oDate->getDay(), 2, '0' , STR_PAD_LEFT ) , $cReturn);
		$cReturn = str_replace( "d", $this->oDate->getDay() , $cReturn);
		$cReturn = str_replace( "yyyy", $this->oDate->getYear() , $cReturn);
		$cReturn = str_replace( "yy", $this->oDate->getShortYear() , $cReturn);
		$cReturn = str_replace( "hh", str_pad($this->oTime->getHours(), 2, '0' , STR_PAD_LEFT )  , $cReturn);
		$cReturn = str_replace( "h", $this->oTime->getHours() , $cReturn);
		$cReturn = str_replace( "ii", str_pad($this->oTime->getMinutes(), 2, '0' , STR_PAD_LEFT )  , $cReturn);
		$cReturn = str_replace( "i", $this->oTime->getMinutes() , $cReturn);
		if ( strpos($cReturn,  "mmmm")  === false )
		{
			$cReturn = str_replace( "mmm", $this->oDate->getMonthShortName() , $cReturn);
			$cReturn = str_replace( "mm", str_pad( $this->oDate->getMonth(), 2, '0' , STR_PAD_LEFT ) , $cReturn);
			$cReturn = str_replace( "m", $this->oDate->getMonth() , $cReturn);
		} else
		{
			$cReturn = str_replace( "mmmm", $this->oDate->getMonthName() , $cReturn);
		}
		return $cReturn ;
	}
	function getLongDescription ()
		{
			return $this->oDate->getLongDescription() . ' a las ' . $this->oTime->getDescription() ;
		}
	function getShortDescription ()
		{
			if ( $this->oDate->isToday() ) return $this->oTime->getDescription() ;
			return $this->oDate->getShortDescription() . ' ' . $this->oTime->getDescription() ;
		}
}
?>